import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { employeeList } from '@apps/ant-bus/src/views/business/employeeManage/employee/data/api';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '会员姓名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '会员卡号',
    dataIndex: 'vipCardNo',
    width: 150,
  },
  {
    title: '卡种',
    dataIndex: 'goodsName',
    width: 150,
  },
  {
    title: '支付金额',
    dataIndex: 'payAmount',
    width: 120,
  },
  {
    title: '抵扣状态',
    dataIndex: 'fullDeductionState',
    width: 150,
    dictData: [
      { label: '已抵扣', value: 0 },
      { label: '已撤销', value: 1, color: '#f31111' },
      { label: '退卡撤销', value: 2, color: '#095ad5' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '抵扣总金额',
    dataIndex: 'fullDeductionAmount',
    width: 150,
  },
  {
    title: '剩余可抵扣金额',
    dataIndex: 'restFullDeductionAmount',
    width: 150,
  },
  {
    title: '开卡日期',
    dataIndex: 'buyDate',
    width: 120,
  },
  {
    title: '所属地区',
    dataIndex: 'airportName',
    width: 150,
  },
  {
    title: '所属销售',
    dataIndex: 'employeeName',
    width: 120,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 150,
    customRender: render.renderTxt,
  },
  {
    title: '操作人',
    dataIndex: 'optUserName',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'vipCardNo',
    label: '会员卡号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'userName',
    label: '会员姓名',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'airportId',
    label: '所属机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    label: '所属销售',
    field: 'employeeId',
    component: 'ApiSelect',
    componentProps: ({ formModel }) => {
      return {
        api: employeeList,
        params: { handlerName: 'busEmployeeListHandler' },
        labelField: 'employeeName',
        valueField: 'employeeId',
        immediate: true,
        showSearch: true,
      };
    },
  },
  {
    field: 'fullDeductionState',
    label: '抵扣状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '已抵扣', value: 0 },
        { label: '已撤销', value: 1 },
        { label: '退卡撤销', value: 2 },
      ],
    },
  },
];
